/*
 * CustomtextBox.fx
 *
 * Created on 7.2.2010, 16:19:
 */

package com.gpsbuddy.components;

import javafx.scene.CustomNode;
import javafx.scene.Node;
import javafx.scene.text.Text;
import javafx.scene.control.TextBox;
import javafx.scene.Group;
import javafx.scene.layout.HBox;
import javafx.geometry.VPos;
import com.gpsbuddy.main.Enviroment;

/**
 * @author jonycus
 */

public class CustomTextBox extends CustomNode {

    public-init var env:Enviroment;

    public var label: String;
    public var text: String;

    var labelComp = Text {
        content: bind label;
    }

    var inputField = TextBox {
            text: bind text with inverse;
    }

    public var container = HBox {
            spacing: 10;
            nodeVPos: VPos.CENTER;
            content: [labelComp, inputField];
    }

    var content = Group {
        content: [container]
    }
        
    override protected function create () : Node {
        return content;
    }

    postinit {
        inputField.columns = (env.screenWidth - labelComp.layoutBounds.width - container.spacing)/12 as Integer;
    }

}
